<extend name="Index:base" />
<block name="stylecss">
    <link rel="stylesheet" href="__PUBLIC__/admin/css/datepicker.css" />
</block>
<block name="content">
    <div class="main-content">
        <div class="breadcrumbs" id="breadcrumbs">

            <!-- 面包屑导航 -->
            <ul class="breadcrumb">
                <li>
                    <i class="icon-home home-icon"></i>
                    <a href="{:U('Admin/Index/index')}">首页</a>
                </li>
                <li>
                    <a href="{:U('Admin/Couponmanage/index')}">{$page['title']['prev']}</a>
                </li>
                <li class="active">
                    {$page['title']['current']}
                </li>
            </ul>
        </div>

        <div class="page-content">

            <!-- 页面导航 -->
            <div class="page-header">
                <h1>
                    {$page['title']['current']}
                    <a class="btn btn-info btn-sm pull-right" href="{:U('Admin/Couponmanage/index')}">
                        <i class="icon-reply icon-only"></i>
                    </a>
                </h1>
            </div>

            <div class="row" style="margin-top:35px;">
                <div class="col-xs-12">
                    <form class="form-horizontal" role="form" action="{:U('Admin/Couponmanage/insertCoupon')}" method="post" enctype="multipart/form-data">
                        <div class="form-group">
                            <label class="col-sm-2 control-label no-padding-right"> 优惠券名称 </label>
                            <div class="col-sm-10">
                                <input class="col-xs-10 col-sm-5" type="text" placeholder="请填写优惠券名称" name="cgname">
                            </div>
                        </div>
                        
                        <div class="form-group">
                            <label class="col-sm-2 control-label no-padding-right"> 优惠券折扣 </label>
                            <div class="col-sm-10">
                                <div class="col-xs-12 col-sm-4">
                                    <span style="float:left;display:block;line-height:30px;color:#05A;font-size:16px;">消费满：</span>
                                    <select class="form-control" style="float:left;width:200px;" name="cgspend">
                                        <option value="0">0</option>
                                        <option value="50">50</option>
                                        <option value="100">100</option>
                                        <option value="200">200</option>
                                        <option value="300">300</option>
                                        <option value="500">500</option>
                                        <option value="1000">1000</option>
                                        <option value="2000">2000</option>
                                    </select>
                                </div>
                                <div class="col-xs-12 col-sm-4">
                                    <span style="float:left;display:block;line-height:30px;color:#05A;font-size:16px;">立减：</span>
                                    <select class="form-control" style="float:left;width:200px;" name="cgreduce">
                                        <option value="10">10</option>
                                        <option value="20">20</option>
                                        <option value="30">30</option>
                                        <option value="50">50</option>
                                        <option value="100">100</option>
                                        <option value="200">200</option>
                                        <option value="300">300</option>
                                        <option value="800">800</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label no-padding-right"> 优惠券使用范围 </label>
                            <div class="col-sm-10" id="selparent">
                                <div id="menu-0" class="col-xs-10 col-sm-2  no-padding">
                                    <select class="form-control" name="cid">
                                        <option value="0">全场通用</option>
                                        <foreach name="data" item="vo">
                                            <option value="{$vo['cid']}"}>{$vo['cname']}专场</option>
                                        </foreach>
                                    </select>
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label no-padding-right"> 优惠券数量 </label>
                            <div class="col-sm-10">
                                <input class="col-xs-10 col-sm-2" type="number" placeholder="请填写优惠券数量" name="cgnums">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label no-padding-right"> 优惠券前缀 </label>
                            <div class="col-sm-10">
                                <input class="col-xs-10 col-sm-2" type="text" placeholder="请填写优惠券前缀" varlue="YHQ_" name="cgprefix">
                            </div>
                        </div>

                        <div class="form-group" >
                            <label class="col-sm-2 control-label no-padding-right"> 活动开始日期 </label>
                            <div class="col-sm-10">
                                <div class="col-xs-10 col-sm-5 no-padding" >
                                    <div class="input-group">
                                        <span class="input-group-addon">
                                            <i class="icon-calendar bigger-90"></i>
                                        </span>
                                        <input style="height:30px;" class="form-control date-picker" id="id-date-picker-2" type="text" data-date-format="yyyy-mm-dd" name="cgstarttime" placeholder="请填写活动开始日期">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="form-group" >
                            <label class="col-sm-2 control-label no-padding-right"> 活动结束日期 </label>
                            <div class="col-sm-10">
                                <div class="col-xs-10 col-sm-5 no-padding" >
                                    <div class="input-group">
                                        <span class="input-group-addon">
                                            <i class="icon-calendar bigger-90"></i>
                                        </span>
                                        <input style="height:30px;" class="form-control date-picker" id="id-date-picker-2" type="text" data-date-format="yyyy-mm-dd" name="cgendtime" placeholder="请填写活动结束日期">
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="clearfix form-actions">
                            <div class="col-md-offset-2 col-md-10">
                                <button class="btn btn-info" type="submit">
                                    <i class="icon-ok bigger-110"></i>
                                    提交
                                </button>
                                &nbsp; &nbsp; &nbsp;
                                <button class="btn" type="reset">
                                    <i class="icon-undo bigger-110"></i>
                                    重置
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</block>
<block name="privatejs">
    <script src="__PUBLIC__/admin/js/date-time/bootstrap-datepicker.min.js"></script>
    <script type="text/javascript">
        $(function(){
            //设置当前页面的菜单高亮显示 开始
            var nownav = '#sidebar a[href*=Couponmanage]';
            var parentattr = $(nownav).parent().parent().attr("class");
            $(nownav).parent().addClass('active');
            if (parentattr == 'submenu') {
                $(nownav).parent().parent().parent().addClass('active open');
            };
            //设置当前页面的菜单高亮显示 结束

            $('.date-picker').datepicker({autoclose:true}).prev().on(ace.click_event, function(){
                $(this).next().focus();
            });

            $("button[type=submit]").on('click',function(){
                if ($(':input').val() == '') {
                    return false;
                };
            });

            //默认打开选项
            $('#selclass').children().eq(0).children().eq(2).addClass('in');

            //全选 
            $("[id^=checkAll-]:checkbox").on('click',function(){
                var num = $(this).prop('id').split('-')[1];
                var divs = "#check-"+num;
                $(divs+" :checkbox").prop("checked",this.checked);
            });
           
            $('[name^=team]:checkbox').click(function(){
                var num = $(this).parent().parent().prop('id').split('-')[1];
                var $tmp = $('#check-'+num+' :checkbox');
                $("#checkAll-"+num).prop('checked',$tmp.length==$tmp.filter(':checked').length);
            });
        });
    </script>
</block>